package com.bootMybatis.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bootMybatis.dao.EBankMapper;
import com.bootMybatis.service.IXjBankEbankService;
import com.bootMybatis.utils.AjaxJson;
import com.bootMybatis.utils.CreateXjBankFile;

@Service(value = "xjBankEbankService")
@Transactional(readOnly = true)
public class XjBankEbankServiceImpl implements IXjBankEbankService {

	// private static final Log logger = LogFactory.getLog(XjBankServiceImpl.class);

	@Autowired
	private EBankMapper eBankMapper;

	@Override
	public AjaxJson OPERATOR_PURVIEW() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成OPERATOR_PURVIEW.txt成功");
		try {
			List<Map<String, Object>> list = eBankMapper.OPERATOR_PURVIEW();
			CreateXjBankFile.INSTANCE.writeFile(list, "OPERATOR_PURVIEW", "ebank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson OPERATOR_TABLE() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成OPERATOR_TABLE.txt成功");
		try {
			List<Map<String, Object>> list = eBankMapper.OPERATOR_TABLE();
			CreateXjBankFile.INSTANCE.writeFile(list, "OPERATOR_TABLE", "ebank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson CB_CST_PAYEE() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成CB_CST_PAYEE.txt成功");
		try {
			List<Map<String, Object>> list = eBankMapper.CB_CST_PAYEE();
			CreateXjBankFile.INSTANCE.writeFile(list, "CB_CST_PAYEE", "ebank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson CB_VOUCHER() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成CB_VOUCHER.txt成功");
		try {
			List<Map<String, Object>> list = eBankMapper.CB_VOUCHER();
			CreateXjBankFile.INSTANCE.writeFile(list, "CB_VOUCHER", "ebank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson CB_ECACLIMIT() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成CB_ECACLIMIT.txt成功");
		try {
			List<Map<String, Object>> list = eBankMapper.CB_ECACLIMIT();
			CreateXjBankFile.INSTANCE.writeFile(list, "CB_ECACLIMIT", "ebank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson CB_ECUSRCERT() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成CB_ECUSRCERT.txt成功");
		try {
			List<Map<String, Object>> list = eBankMapper.CB_ECUSRCERT();
			CreateXjBankFile.INSTANCE.writeFile(list, "CB_ECUSRCERT", "ebank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}
}
